package com.gz.servlet.httpservletrequest;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns = "/mangerServlet")
public class MangerServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        String pwd = request.getParameter("pwd");

         String role=(String)request.getAttribute("role");
         response.setContentType("text/html;charset=utf-8");
         PrintWriter writer = response.getWriter();
         writer.println("<h1>用户: "+username+"</h1>");
         writer.println("<h1>role: "+role+"</h1>");
         writer.flush();
         writer.close();
    }
}
